package com.example.scns;
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;


//쇼핑 목록
public class ListViewActivity extends Activity {
	
	private ArrayList<InfoClass> mCareList = null;
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rowmain);
        
        setLayout();
        
        mCareList = new ArrayList<InfoClass>();
         
    	mCareList.add(new InfoClass
				("야채", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("과일", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("육가공류", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("생선", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("육류", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("유제품", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("라면", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("과자", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("음료", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("생활용품", getResources().getDrawable(R.drawable.ic_launcher), ""));
    	mCareList.add(new InfoClass
				("곡류", getResources().getDrawable(R.drawable.ic_launcher), ""));
       
        // BaseAdapter 연결
        mListView.setAdapter(new CustomBaseAdapter(this, mCareList));
        
        // ArrayAdapter 연결
//        mListView.setAdapter(new CustomArrayAdapter(this, R.layout.list_row, mCareList));
        
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			public void onItemClick(AdapterView<?> arg0, View view, int position,
					long arg3) {			
				Toast.makeText(
						getApplicationContext(), 
						"ITEM CLICK = " + position,
						Toast.LENGTH_SHORT
						).show();  
			}
		});
    }    
    private ListView mListView = null;
    private void setLayout(){
    	mListView = (ListView) findViewById(R.id.lv_list);
    }
}


